// Copyright (c) 2009 Hypirinha contributers
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.output.print;

import static org.hypirinha.html.ElementFactory.*;
import org.hypirinha.html.elements.Html;
import org.hypirinha.html.elements.Ul;
import static org.hypirinha.html.output.print.MultilineString.lines;
import org.hypirinha.html.output.features.HtmlNamespace;
import org.hypirinha.html.output.PrintAdapter;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class NamespaceTest {

    @Test
    public void shouldIncludeNamespaceIfSupplied() {
        Html content = html();

        String output = new PrintAdapter(HtmlNamespace.xhtml1).asString(content);

        assertEquals(lines(
                "<html xmlns=\"http://www.w3.org/1999/xhtml\"></html>"), output);
    }



    @Test
    public void shouldOnlySpecifyNamespaceOnTheOutermostElement() {
        Ul content = ul().contains(li(), li());

        String output = new PrintAdapter(HtmlNamespace.xhtml1).asString(content);

        assertEquals(lines(
                "<ul xmlns=\"http://www.w3.org/1999/xhtml\">",
                "  <li></li>",
                "  <li></li>",
                "</ul>"), output);
    }

}